{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "ff66058d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy\n",
    "import pandas"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e3700091",
   "metadata": {},
   "source": [
    "# pandas分箱操作"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "57faf070",
   "metadata": {},
   "source": [
    "- 分箱操作就是将连续型数据离散化\n",
    "- 分箱操作分为等距分箱和等频分箱"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "28335177",
   "metadata": {},
   "source": [
    "- cut()\n",
    "- qcut()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "155c3707",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>python</th>\n",
       "      <th>pandas</th>\n",
       "      <th>pytorch</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>42</td>\n",
       "      <td>27</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>86</td>\n",
       "      <td>28</td>\n",
       "      <td>98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>97</td>\n",
       "      <td>15</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>82</td>\n",
       "      <td>93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>99</td>\n",
       "      <td>73</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   python  pandas  pytorch\n",
       "0      42      27        3\n",
       "1      86      28       98\n",
       "2      97      15       13\n",
       "3       4      82       93\n",
       "4      99      73       19"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = numpy.random.randint(0,100,size=(5,3))\n",
    "df = pandas.DataFrame(data=data,columns=['python','pandas','pytorch'])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5a5c318c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     (27.75, 51.5]\n",
       "1     (75.25, 99.0]\n",
       "2     (75.25, 99.0]\n",
       "3    (3.905, 27.75]\n",
       "4     (75.25, 99.0]\n",
       "Name: python, dtype: category\n",
       "Categories (4, interval[float64, right]): [(3.905, 27.75] < (27.75, 51.5] < (51.5, 75.25] < (75.25, 99.0]]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 等距分箱\n",
    "s = pandas.cut(df.python,bins=4) # 这里的bins是分成几组\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "7ebefb6d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: xlabel='python'>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAIGCAYAAACGS480AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8pXeV/AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA0fUlEQVR4nO3deVRV5f7H8c/B4YgpK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29fx/ZDhw7V0aNHFRsbq5SUFC1cuFALFizQ6NGjC/dbAACAEsulyzQnTpzQU089pbS0NPn6+qpJkyZas2aNunXrJklKS0vTsWPHHNuHhYVp1apVGjVqlGbOnKng4GBNnz5dffr0KdxvAQAASqxbnmekOJieZ4S7aQAAcF2RzzMCAABQGAgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjHIpjMTFxally5aqXLmy/P391bt3b+3fv/+6+yQmJspms+V57du375YKBwAAnsGlMLJp0yYNGzZM27Zt0/r163Xx4kVFR0fr3LlzN9x3//79SktLc7zq169f4KIBAIDnKOvKxmvWrHFajo+Pl7+/v3bu3KmOHTted19/f39VqVLF5QIBAIBnu6UxIxkZGZIkPz+/G27brFkzBQUFKSoqShs3brzutllZWcrMzHR6AQAAz1TgMGJZlmJjY9W+fXs1btz4mtsFBQVp7ty5SkhI0KeffqqGDRsqKipKX3/99TX3iYuLk6+vr+MVEhJS0DIBAICbs1mWZRVkx2HDhmnlypX65ptvVLNmTZf2jYmJkc1m04oVK/Jtz8rKUlZWlmM5MzNTISEhysjIkI+PT0HKvSWhL60s9s90B0feuNd0CQCAEiwzM1O+vr43/P1doJ6R4cOHa8WKFdq4caPLQUSS2rRpo4MHD16z3W63y8fHx+kFAAA8k0sDWC3L0vDhw7V8+XIlJiYqLCysQB+anJysoKCgAu0LAAA8i0thZNiwYVq6dKk+//xzVa5cWenp6ZIkX19feXt7S5LGjRun48ePa/HixZKkadOmKTQ0VBEREcrOztaSJUuUkJCghISEQv4qAACgJHIpjMyePVuS1LlzZ6f18fHx6t+/vyQpLS1Nx44dc7RlZ2dr9OjROn78uLy9vRUREaGVK1eqV69et1Y5AADwCAUewFqcbnYATFFhACsAAK4r0gGsAAAAhYUwAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKNcCiNxcXFq2bKlKleuLH9/f/Xu3Vv79++/4X6bNm1S8+bNVaFCBdWpU0dz5swpcMEAAMCzuBRGNm3apGHDhmnbtm1av369Ll68qOjoaJ07d+6a+xw+fFi9evVShw4dlJycrPHjx2vEiBFKSEi45eIBAEDJV9aVjdesWeO0HB8fL39/f+3cuVMdO3bMd585c+aoVq1amjZtmiQpPDxcSUlJmjp1qvr06VOwqgEAgMe4pTEjGRkZkiQ/P79rbrN161ZFR0c7revevbuSkpKUk5NzKx8PAAA8gEs9I1ezLEuxsbFq3769GjdufM3t0tPTFRAQ4LQuICBAFy9e1KlTpxQUFJRnn6ysLGVlZTmWMzMzC1omAABwcwXuGXn++ef1/fff68MPP7zhtjabzWnZsqx8118RFxcnX19fxyskJKSgZQIAADdXoDAyfPhwrVixQhs3blTNmjWvu21gYKDS09Od1p08eVJly5ZVtWrV8t1n3LhxysjIcLxSU1MLUiYAACgBXLpMY1mWhg8fruXLlysxMVFhYWE33CcyMlJffPGF07p169apRYsWKleuXL772O122e12V0oDAAAllEs9I8OGDdOSJUu0dOlSVa5cWenp6UpPT9f58+cd24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owgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwCjCCAAAMIowAgAAjCKMAAAAowgjAADAKMIIAAAwijACAACMIowAAACjCCMAAMAowggAADCKMAIAAIwijAAAAKMIIwAAwKgChZFZs2YpLCxMFSpUUPPmzbV58+ZrbpuYmCibzZbntW/fvgIXDQAAPIfLYWTZsmUaOXKkXn75ZSUnJ6tDhw7q2bOnjh07dt399u/fr7S0NMerfv36BS4aAAB4DpfDyDvvvKNBgwZp8ODBCg8P17Rp0xQSEqLZs2dfdz9/f38FBgY6XmXKlClw0QAAwHO4FEays7O1c+dORUdHO62Pjo7Wli1brrtvs2bNFBQUpKioKG3cuNH1SgEAgEcq68rGp06d0qVLlxQQEOC0PiAgQOnp6fnuExQUpLlz56p58+bKysrSP/7xD0VFRSkxMVEdO3bMd5+srCxlZWU5ljMzM10pEwAAlCAuhZErbDab07JlWXnWXdGwYUM1bNjQsRwZGanU1FRNnTr1mmEkLi5OEydOLEhpAACghHHpMk316tVVpkyZPL0gJ0+ezNNbcj1t2rTRwYMHr9k+btw4ZWRkOF6pqamulAkAAEoQl8JI+fLl1bx5c61fv95p/fr169W2bdubfp/k5GQFBQVds91ut8vHx8fpBQAAPJPLl2liY2P11FNPqUWLFoqMjNTcuXN17NgxDR06VNLlXo3jx49r8eLFkqRp06YpNDRUERERys7O1pIlS5SQkKCEhITC/SYAAKBEcjmMPPLII/rtt980adIkpaWlqXHjxlq1apVq164tSUpLS3OacyQ7O1ujR4/W8ePH5e3trYiICK1cuVK9evUqvG8BAABKrAINYH3uuef03HPP5du2aNEip+WxY8dq7NixBfkYAABQCvBsGgAAYBRhBA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Ly3fTxMbGav78+Vq4cKFSUlI0atQoHTt2TEOHDpV0+RJL3759HdsPHTpUR48eVWxsrFJSUrRw4UItWLBAo0ePLrxvAQAASiyXx4w88sgj+u233zRp0iSlpaWpcePGWrVqlWrXri1JSktLc5pzJCwsTKtWrdKoUaM0c+ZMBQcHa/r06erTp0/hfQsPZbfb9eqrr+a5ZAXPxPEuXTjepQvH+/ps1o3utwEAAChCPJsGAAAYRRgBAABGEUYAAIBRhBEAAGAUYQQAABhVoOngUXimT5/u8j4DBgxQ5cqVi6AaFLUVK1a4vE+3bt3k7e1dBNWgqHF+ly4c74Lj1l7DvLy8VLNmTZUpU+amtk9NTdWBAwdUp06dIq4MRcHLy7XOSJvNpoMHD3K8SyjO79KF411w9Iy4gaSkJPn7+9/UtiToki89PZ3jXYpwfpcuHO+CYcyIYa+++qoqVap009uPHz9efn5+RVgRilK/fv1cuuTy5JNPlrqHankSzu/SheNdcFymAQAARnGZxs1cunRJp06dks1mU7Vq1W762iMAACUVl2ncxPLly9WuXTtVrFhRwcHBCgoKUsWKFdWuXTt99tlnpstDIcrOznZaPnTokEaOHKl7771XgwcP1s6dOw1VhqJw4MABXd0B/c0336h3796KiIhQ165d9fnnnxusDoWN410whBE38Pe//12PPvqomjRpomXLlumbb77R5s2btWzZMjVp0kSPPvqo5s2bZ7pMFBJvb2+dPHlSkrR79241adJEmzZtUo0aNfT999+rbdu22r59u+EqUVjCw8P166+/SpISExPVqVMn5ebm6oknnlCVKlX00EMPae3atYarRGHheBcMY0bcQL169TRu3DgNGjQo3/aFCxfq9ddf16FDh4q5MhQFLy8vxx01MTExqlChgj7++GPZbDZJ0sCBA5WWlqbVq1cbrhSF4erj3bVrVzVs2FAzZ850tI8bN05btmzRpk2bDFaJwsLxLhh6RtzA8ePH1b59+2u2t23bVr/88ksxVoTisnv3bo0cOdIRRCTphRdeUHJyssGqUFR+/PFH9e3b12ndU089pb179xqqCEWJ433zCCNuICIiQnPnzr1m+7x58xQREVGMFaEo2Ww2R/goU6ZMnlt3fXx8lJGRYaI0FJEzZ84oMzNT3t7estvtTm3ly5fX+fPnDVWGosDxdh1307iBt99+W/fee6/WrFmj6OhoBQQEyGazKT09XevXr9fRo0e1atUq02WikFiWpQYNGshms+ns2bP64YcfdOeddzraDx48qMDAQIMVorA1aNBA0uVjv3PnTjVt2tTRtnfvXtWoUcNQZSgKHG/XEUbcQKdOnfTvf/9bs2fP1rZt25Seni5JCgwM1H333aehQ4cqNDTUbJEoNPHx8U7LdevWdVretm2bHnzwweIsCUVo48aNTstBQUFOy0eOHNGQIUOKsyQUIY53wTCAFQAAGMWYEQAAYBRhpATo16+funTpYroMFJI777xTkydPVmpqqulS4AY4vz3PypUrNXjwYI0dO1b79u1zavv999853vkgjJQANWrUUO3atU2XgUKyd+9evfvuuwoLC1OPHj2UkJCgixcvmi4LhnB+e5alS5fqgQceUHp6urZu3apmzZrpgw8+cLRnZ2czx0g+GDMCFDMvLy/9/PPP2r59uxYuXKjVq1eratWq6tu3rwYNGqTw8HDTJQIooLvvvlsDBgzQ8OHDJUmffPKJBgwYoGnTpmnQoEE6ceKEgoODdenSJcOVuhfCCFDMrp6hUZLS09MVHx+v+Ph4HTp0SK1bt9bgwYM1cOBAw5UCcFWlSpX0ww8/KCwszLEuMTFR999/v/72t7/pwQcfJIzkg8s0biItLU2vvPKKunTpovDwcDVu3FgxMTFasGAB/2g9zNWzrUqXb+EeN26cDhw4oA0bNqhu3boaMWKEoepQ3FJTUwmeHsTHx0cnTpxwWte5c2d98cUXGjNmjGbMmGGoMvdGz4gbSEpKUteuXRUWFiZvb2999913euKJJ5Sdna21a9cqPDxca9euVeXKlU2XikLw556R/GRmZuaZmRWeac+ePbr77rv5o8ND9O7dW3fddZcmTpyYpy0xMVH33Xefzp8/z/H+EyY9cwMjR47UqFGj9Oqrr0qSlixZovfee0/btm1zjLz+y1/+onfffddwpSgM/fr1k7e393W3IYh4jhUrVly3/aeffiqmSlAcRo0apS1btuTb1rlzZ3355Zd6//33i7kq90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B43XXntN48ePdyzPnz9fs2bNuu7EaKURPSNuID4+njEhcNiwYQO3AHqQl156STt37sy3LSIiQhs3btQnn3xSzFWhqNzoTpnAwECnAcy4jJ4RAABgFBeuDDt27JhL23N92XOdOHHC5X8PcG+c36ULx7vgCCOGtWzZUkOGDNH27duvuU1GRobmzZunxo0b69NPPy3G6lAUzpw5oyeffFK1a9dWv379lJ2drWHDhikoKEhhYWHq1KmTMjMzTZeJQsD5XbpwvAuOyzSGnT59WlOmTNHChQtVrlw5tWjRQsHBwapQoYJ+//13/fjjj9q7d69atGihv/zlL+rZs6fpknGLhg8frn/961967rnn9Omnn8rX11eHDh3SnDlzlJubq+eee07333+/Xn/9ddOl4hZxfpcuHO+CI4y4iQsXLmjVqlXavHmzjhw5ovPnz6t69epq1qyZunfvrsaNG5suEYWkVq1aev/993XPPffol19+Uc2aNfX5558rJiZGkrRq1SrFxsbyoDwPwvldunC8XUcYAYpZhQoVdPDgQYWEhEiSbrvtNiUnJ6tBgwaSpKNHj6pRo0Y6d+6cyTIBoNgwZgQoZtWqVdOvv/7qWH7ggQdUpUoVx/LZs2dlt9sNVAYAZhBGgGLWpEkT7dixw7G8dOlSpwnvduzYofDwcBOlAYARXKYBitnp06fl5eXl1BtytdWrV8vb21udO3cu1roAwBTCCAAAMIrLNEAxYlIkAMiLMAIUIyZFAoC8eFAeUIxSUlI0ZcoU9ejR44aTIr311ltMigSgVGDMCGAAkyIBwP8jjAAAAKMYMwIAAIwijAAAAKMIIwAAwCjCCAAAMIowAsCYI0eOyGazaffu3aZLAWAQYQRAsejfv7969+5tugwAbogwAgAAjCKMALgpnTt31vPPP6/nn39eVapUUbVq1fSXv/xFlmVp0qRJuvPOO/Ps07x5c73yyiv661//qvfff1+ff/65bDabbDabEhMTHdv99NNPuueee1SxYkXddddd2rp1q9P7JCQkKCIiQna7XaGhoXr77bed2kNDQzVlyhQNHDhQlStXVq1atTR37twi+f8AoAhYAHATOnXqZFWqVMl64YUXrH379llLliyxKlasaM2d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ijAAAAKP+DzoYgGEL+vE4AAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "s.value_counts().plot.bar()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1e75b655",
   "metadata": {},
   "source": [
    "---"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "113eddc6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 等频分箱\n",
    "s = pandas.qcut(df.python,q=4) # 这里q=4表示分成4等份"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
